package com.ckv.qcm.model;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;

import com.ckv.qcm.model.dao.TraineeDAO;

public class Trainee extends User
{

	private long idPromotion;

	private static TraineeDAO dao = new TraineeDAO();

	public Trainee()
	{
		super();
	}

	public Trainee(long idStagiaire, long idPromotion, String nom, String prenom,String password)
	{
		super(idStagiaire, nom, prenom,password);
		this.idPromotion = idPromotion;
	}
	
	public ArrayList<Session> getCurrentSessions() throws SQLException
	{
		ArrayList<Session> sessions = new ArrayList<Session>();
		
		ArrayList<Long> idSessions = dao.getSessionIds(this.getId(),new Date());
		
		for (Long id  : idSessions)
		{
			sessions.add(Session.find(id));
		}
		
		return sessions;
	}
	
	public static Trainee find(String name, String password)
	{
		return dao.find(name, password);
	}

	public static Trainee find(long id)
	{
		return dao.find(id);
	}

	public static ArrayList<Trainee> findAll()
	{
		return dao.findAll();
	}

	public long getIdPromotion()
	{
		return idPromotion;
	}

	public void setIdPromotion(long idPromotion)
	{
		this.idPromotion = idPromotion;
	}
}
